package com.atguigu.sparkcore.rdd.tranformdoublevalue

import com.atguigu.sparkcore.util.MySparkContextUtil
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

/**
  * 笛卡尔集
  * author 剧情再美终是戏
  * mail 13286520398@163.com
  * date 2020/1/6 16:57 
  * version 1.0
  **/
object Cartesian {

  def main(args: Array[String]): Unit = {

    // 获取sparkContext
    val sc = MySparkContextUtil.get(args)

    // 创建rdd
    val rdd: RDD[Int] = sc.makeRDD((1 to 4), 2)
    val rdd2: RDD[Int] = sc.makeRDD(Array(2, 3, 5), 2)

    // 操作rdd
    val result = rdd.cartesian(rdd2)

    result.foreach(println)

    // 关闭资源
    MySparkContextUtil.close(sc)
  }
}
